
type FieldTypeBase =
  | 'text'
  | 'keyword'
  | 'long'
  | 'integer'
  | 'short'
  | 'byte'
  | 'double'
  | 'float'
  | 'boolean'
  | 'date'
  | 'ip'
  | 'geo_point'
  | 'object'
  | 'nested'
  | 'flattened';

type FieldTypeObj = 'object' | 'nested';
type FieldType = FieldTypeBase | FieldTypeObj;

interface MappingPropertyBase {
  // 字段名
  field: string;

  type: FieldTypeBase;
  index?: boolean;
  analyzer?: string;
  search_analyzer?: string;
  norms?: boolean;
  doc_values?: boolean;
  fielddata?: boolean;
  copy_to?: string | string[];
  format?: string;
  null_value?: any;
  ignore_above?: number;

}

interface MappingPropertyObj {
  // 字段名
  field: string;

  type: FieldTypeObj;
  index?: boolean;
  analyzer?: string;
  search_analyzer?: string;
  norms?: boolean;
  doc_values?: boolean;
  fielddata?: boolean;
  copy_to?: string | string[];
  format?: string;
  null_value?: any;
  ignore_above?: number;
  properties: Array<MappingProperty>;

}

export type MappingProperty = MappingPropertyBase | MappingPropertyObj;

export interface IndexMapping {
  dynamic?: boolean | 'strict' | 'runtime';
  properties: Array<MappingProperty>;
}
